#include <REGX52.H>
#include "Delay.h"
#include "Nixie.h"
#include "Key.h"
#include "Time0.h"

unsigned char Counter,Compare;
unsigned char keyNum, speed;
sbit MOTOR = P1^1;

void main() {
	Timer0Init();
	while (1) {
		
		keyNum = Key();
		if (keyNum== 1) {
			speed++;
			speed %= 4;
			if (speed == 0) {
				Compare = 100;
			}
			if (speed == 1) {
				Compare = 50;
			}
			if (speed == 2) {
				Compare = 50;
			}
			if (speed == 3) {
				Compare = 0;
			}
		}
		Nixie(1,speed);
			
	}
	
}

void Timer0_Routine() interrupt 1 {
	
	TL0 = 0x9C;		//设置定时初值
	TH0 = 0xFF;		//设置定时初值
	Counter++;
	Counter %= 100;
	if (Counter < Compare) {
		MOTOR = 0;
	} else {
		MOTOR = 1;
	}
	
}